<?php

namespace App\Core;

use App\Core\Traits\HasProps;
use App\Core\Traits\HasStates;
use VueRender\Support\Js;

class Schema
{
    protected string $componentName = "";
    protected array $states = [];
    protected array $props = [];
    protected array $binds = [];
    protected array $methods = [];
    protected array $styles = [];
    protected array $condition = [];

    use HasStates, HasProps;

    public function __construct(){

    }

    /**
     * 设置组件名称
     * @param string $componentName
     * @return $this
     */
    public function componentName(string $componentName): static
    {
        $this->componentName = $componentName;
        return $this;
    }

    /**
     * @return string
     */
    public function getComponentName(): string
    {
        return $this->componentName;
    }

    /**
     * @param string $prop
     * @param string $stateKey
     * @param mixed $default
     * @return $this
     */
    public function bind(string $prop, string $stateKey, mixed $default = null): static
    {
        $this->binds[$prop] = [
            'type'=>'bind',
            'key'=>$prop,
            'value'=>$stateKey
        ];
        if (str_contains($stateKey,".")){

        }
        $this->state($stateKey, $default);
        return $this;
    }

    /**
     * @param string $bind
     * @param string $value
     * @return $this
     */
    public function bind(string $bind, mixed $value): static
    {
        $this->binds[$bind] = $value;
        return $this;
    }



    public function toJson(){
        return [
            'com'
        ];
    }

    public function toHtml(){

    }

}
